<?php
namespace app\common\validate;
use think\Validate;
/**
 * 菜单验证器
* @author xuyunlong <416319808@qq.com>
 */
class Menu extends Validate
{
    protected $rule = [
        'id'    => 'require|number|gt:0',
        'title'  =>  'require|min:2',
        'url' =>  'require|unique:menu',
        'pid' => 'require|number|egt:0'
    ];
    protected $message = [
        'id.require' => '菜单id不能为空',
        'id.number' => '菜单id必须是数字',
        'id.gt' => '菜单id异常',
        'title.require' => '菜单名不能为空',
        'title.min' => '菜单名不能小于两位',
        'url.require' => 'url不能为空',
        'url.unique' => 'url已存在',
        'pid.require' => 'pid不能为空',
        'pid.number' => 'pid必须是数字',
        'pid.egt' => 'pid异常',
    ];
    protected $scene = [
        'add'  =>  ['title','url'],
        'edit' => ['id', 'title', 'url']
    ];

}
